package com.baselibrary.libs.View.multiseriate;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.LinearLayout;

import com.baselibrary.libs.R;
import com.baselibrary.libs.View.baseView.BaseView;
import com.baselibrary.libs.View.multiseriate.bean.Items;

import java.util.ArrayList;

/**
 * Created by Administrator 于萌萌
 * 创建日期: 15:26 . 2017年03月20日
 * 描述:多行 多列
 * <p>
 * <p>
 * 备注:
 */

public class Multiseriate extends BaseView{
    ArrayList<Items> mItemses = new ArrayList<>();

    private LinearLayout mLl_add;

    public Multiseriate(Context context) {
        super(context);
    }

    public Multiseriate(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public Multiseriate(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    public int getXml() {
        return R.layout.multiseriate;
    }

    @Override
    public void initView(View view) {
        mLl_add = (LinearLayout)view.findViewById(R.id.ll_add);


    }

    /**
     * 设定 item 属性集合
     * @param mItemses
     * @return
     */
    public Multiseriate setData(ArrayList<Items> mItemses){
        this.mItemses =  mItemses;
        return this;
    }

    public void add(Context context){
        LinearLayout linearLayout = new LinearLayout(context);
        LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.WRAP_CONTENT, 1);
        LinearLayout.LayoutParams params1 = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
        linearLayout.setLayoutParams(params1);
        for (int i = 0; i < mItemses.size(); i++) {
            Items items = mItemses.get(i);
            MultiseriateItem item = new MultiseriateItem(context);


            item.setLayoutParams(params);

            linearLayout.addView(item);

        }
        mLl_add.addView(linearLayout);
    }
}
